home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Snippets / DirectoryPopup 1.0 / About DirectoryPopup next >
Encoding:
Text File  |  1996-06-03  |  1.6 KB  |  19 lines  |  [ttro/ttxt]

  1.  
  2. DirectoryPopup Sample
  3.  
  4. Written by Marco Piovanelli <mailto:piovanel@kagi.com>
  5.  
  6. This folder contains some sample code that shows how to display a navigation pop-up menu like the one shown by version 7.x of the Finder when you command-click a window title.
  7. Here’s a short description of the relevant calls:
  8.  
  9.   MenuRef BuildDirectoryMenu ( const FSSpec * inFileSpec ) ;
  10.  
  11. This call takes a file system specification referring to some document and creates a new menu ready to be displayed in a window title bar or somewhere else.  The first item in the menu corresponds to the document itself; additional items refer to the enclosing folders and/or disk.  Each menu item has an associated small icon, just like the Finder.  If the menu cannot be created for some reason, this call returns nil.
  12.  
  13.   Boolean TrackDirectoryPopup ( FSSpec * ioFileSpec,
  14.                WindowRef inWindow, Point inHitPt ) ;
  15.  
  16. Call this when you detect a command-click in the drag bar of the frontmost window.  Pass in the window reference, the specification of the file associated with the window and the hit point (in local coordinates): TrackDirectoryPopup will check to see if the click went into the title bar area of the window, create a directory menu (using BuildDirectoryMenu), display the menu and do all the necessary mouse tracking.  If a selection is made, TrackDirectoryPopup will return true and set ioFileSpec to the specification of the selected folder.
  17.  
  18. To show this code in action, I have included a small sample application: DPSample.  Just drag any file onto DPSample and command-click the title bar of the resulting window.
  19. Warning: the sample application requires System 7.0 and a 68020+ CPU.